<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.liit.util.PropertiesUtils"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="cn.liit.weixin.core.config.Config"%>
<%request.setAttribute("vEnter", "\r\n");//处理换行%> 
<!DOCTYPE html>
<html>
<head>
<title>${partyFormMap.subject }</title>
<%@include file="/common/wxCommon.jspf"%>
<style>
.tip {
	width: 16px;
	margin-right: 5px;
	display: block;
}

.weui_cells {
	background-color: #F1F1F1;
	margin-top: 0px;
}

.weui-row {
	width: 100%;
}

.auto-line {
	word-wrap:break-word;
	word-break:break-all;
}
.mwidth {
	min-width: 80px;
}
</style>
</head>
<body>
	<div class="bd">
		<div class="weui_cell">${partyFormMap.subject }</div>
		<div class="weui_cells">
			<div class="weui_cell">
				<div class="weui_cell_hd">
					<img src="${ctx }/images/weixin/time.png" class="tip" />
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<p>
						<fmt:formatDate value="${partyFormMap.startTime }" pattern="M/dd HH:mm" />
						至
						<fmt:formatDate value="${partyFormMap.endTime }" pattern="M/dd HH:mm" />
					</p>
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd">
					<img src="${ctx }/images/weixin/address.png" class="tip" />
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<p>${partyFormMap.province}${partyFormMap.city}${partyFormMap.area}${partyFormMap.street}
						${partyFormMap.address }</p>
				</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_hd">
					<img src="${ctx }/images/weixin/people.png" class="tip" />
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<p>
						已有
						<label style="color: red">${signs }</label>
						人报名
					</p>
				</div>
			</div>
		</div>
		<div class="weui_cells_title">活动详情</div>
		<div class="weui_cell auto-line">${fn:replace(partyFormMap.description,vEnter,"<br>")}</div>
		<c:if test="${not empty partyFormMap.partyImage }">
			<div class="weui_cell">
				<img src="${ctx}/upload/party/${partyFormMap.partyImage }" width="100%">
			</div>
		</c:if>
		<div class="weui_cells_title">活动简介</div>
		<div class="weui_cells">
			<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary mwidth">
					<p>联&thinsp;&thinsp;系&thinsp;&thinsp;人</p>
				</div>
				<div class="weui_cell_ft">${partyFormMap.contact }</div>
			</div>
			<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary mwidth">
					<p>联系电话</p>
				</div>
				<div class="weui_cell_ft">${partyFormMap.phone }</div>
			</div>
			<c:if test="${not empty partyFormMap.notice }">
			<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary mwidth">
					<p>注意事项</p>
				</div>
				<div class="weui_cell_ft">${partyFormMap.notice }</div>
			</div>
			</c:if>
			<c:if test="${not empty partyFormMap.attendTarget }">
			<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary mwidth">
					<p>参与对象</p>
				</div>
				<div class="weui_cell_ft">${partyFormMap.attendTarget }</div>
			</div>
			</c:if>
		</div>
		<div>&nbsp;</div>
		<c:set var="isSignFinish" value="${now > partyFormMap.startTime.time }"></c:set>
		<c:if test="${not empty isSignParty }">
			<div class="content-padded">
				<button type="button" ${isSignFinish or isSignParty ? 'disabled' : ''} class="weui_btn weui_btn_warn">${isSignParty ? '您已报名' : isSignFinish ? '报名已结束' : '报名活动'}</button>
			</div>
		</c:if>
	</div>
	<script type="text/javascript">
		$(function() {
			<c:if test="${isSignFinish }">
				setTimeout(function(){
					$.noti({
				        title: "提醒",
				        text: "活动报名已结束,如需要参加活动,请到活动现场扫码参与!",
				        media: "<i class='weui_icon_info_circle'></i>",
				        time: 8000,
				        onClick: function(data) {
				        	$.closeNotification();
				        }
				    });
				},1000);
			</c:if>
			<c:if test="${!isSignParty }">
			//报名活动
			$("button").click(function(){
				location.href = "${ctx}/weixin/user/party/sign.shtml?partyId=${partyFormMap.id}";
			});
			</c:if>
		});
		
		//微信分享处理
		wx.ready(function(){
			var signPartyUrl = "<%=String.format(PropertiesUtils.findPropertiesKey("auth.url"), 
								Config.appid, URLEncoder.encode(Config.notifyurl + request.getContextPath()
									+ "/weixin/user/party/signParty.shtml?partyId=" , "UTF-8") + "{0}")%>"
								.replace("{0}", "${partyFormMap.id }");
			var partyImage = "<%=Config.notifyurl  + request.getContextPath()%>/upload/party/${partyFormMap.partyImage }";
			wx.onMenuShareTimeline({
			    title: '${partyFormMap.subject }', // 分享标题
			    link: signPartyUrl, // 分享链接
			    imgUrl: partyImage // 分享图标
			});
			
			wx.onMenuShareAppMessage({
			    title: '${partyFormMap.subject }', // 分享标题
			    desc: '${fn:replace(partyFormMap.description,vEnter,"")}', // 分享描述
			    link: signPartyUrl, // 分享链接
			    imgUrl: partyImage // 分享图标
			});
			
			wx.hideMenuItems({
			      menuList: [ 'menuItem:share:qq', 'menuItem:share:weiboApp',  'menuItem:share:QZone' ]
			});
		});
	</script>
	
</body>
</html>